module Environment where

import qualified Data.Map as Map
import Identifier


data Environment a = Environment (Map.Map Identifier a)
                     deriving (Show)


lookup :: Identifier -> Environment a -> Maybe a
------------------------------------------------
lookup id (Environment env) = Map.lookup id env


bind :: Identifier -> a -> Environment a -> Environment a
---------------------------------------------------------
bind id x (Environment env) = Environment $ Map.insert id x env


multibind :: [(Identifier, a)] -> Environment a -> Environment a
----------------------------------------------------------------
multibind pairs env = foldl (\env (id, v) -> bind id v env) env pairs


empty :: Environment a
----------------------
empty = Environment Map.empty

